package cn.fsw.pethome.annotations;

import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener//申明自定义的web监听器，被容器注册和使用
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    private IPermissionScanService permissionScanService;

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    permissionScanService.scanPermission();
                    System.out.println("执行");
                }
            }).start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
